import { RouterProvider, createBrowserRouter } from "react-router-dom";
import routes from "./router";
import React from "react";
import { Provider } from "react-redux";
import { store,persistor  } from "./store";

import { PersistGate } from "redux-persist/integration/react";

// 判断是否运行在 qiankun 中
const isQiankun = window.__POWERED_BY_QIANKUN__;

// 创建路由实例
const router = createBrowserRouter(routes, {
  basename: isQiankun ? "/user/" : "/", // 关键配置
});
const App = () => {
  console.log(router.basename);
  return (
    <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
        <RouterProvider router={router} />
      </PersistGate>
    </Provider>
  );
};

export default App;
